{% extends "base.html" %}

{% block title %}最近私聊{% endblock %}

{% block extra_css %}
<style>
    /* 最近私聊页面样式 */
    .recent-chats-container {
        max-width: 800px;
        margin: 2rem auto;
        padding: 2rem;
        background: var(--card-bg);
        border-radius: var(--border-radius);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .page-title {
        color: var(--accent);
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* 联系人列表 */
    .contacts-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .contact-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: var(--border-radius);
        transition: var(--transition);
        display: flex;
        align-items: center;
    }

    .contact-item:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: translateY(-2px);
    }

    .contact-avatar {
        width: 40px;
        height: 40px;
        background: var(--primary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 1rem;
        font-weight: bold;
        color: white;
    }

    .contact-name {
        font-weight: 500;
        color: var(--light);
        flex-grow: 1;
    }

    .contact-link {
        text-decoration: none;
        color: inherit;
        display: flex;
        align-items: center;
        width: 100%;
    }

    .contact-link:hover {
        text-decoration: none;
    }

    .new-chat-icon {
        margin-left: auto;
        color: var(--accent);
        opacity: 0;
        transition: var(--transition);
    }

    .contact-item:hover .new-chat-icon {
        opacity: 1;
    }

    /* 空状态提示 */
    .empty-state {
        text-align: center;
        padding: 2rem;
        color: var(--gray);
    }

    /* 响应式设计 */
    @media (max-width: 768px) {
        .recent-chats-container {
            padding: 1.5rem;
            margin: 1rem;
        }

        .page-title {
            font-size: 1.5rem;
        }
    }
</style>
{% endblock %}

{% block content %}
<div class="recent-chats-container">
    <h2 class="page-title">最近私聊</h2>

    {% if contacts %}
        <ul class="contacts-list">
            {% for contact in contacts %}
                <li class="contact-item">
                    <a href="{% url 'PrivateChat:private_room' room_key=contact.room_key %}" class="contact-link">
                        <div class="contact-avatar">{{ contact.peer_username|slice:":1"|upper }}</div>
                        <span class="contact-name">{{ contact.peer_username }}</span>
                        <span class="new-chat-icon">➔</span>
                    </a>
                </li>
            {% endfor %}
        </ul>
    {% else %}
        <div class="empty-state">
            <p>暂无私聊记录</p>
            <p>开始与朋友聊天吧</p>
        </div>
    {% endif %}
</div>
{% endblock %}